/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
    height: 100vh;
}

/* Main container - responsive height */
.main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Full screen mode detection */
@media (min-height: 600px) {
    .main-container {
        height: 90vh;
    }
}

/* Control panel at the top */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 2px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    align-items: center;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.control-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    cursor: help;
}

/* Slider styling */
.slider {
    width: 80px;
    height: 20px;
    background: linear-gradient(to right, #4CAF50, #2196F3);
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    border: none;
}

/* Select and input styling */
select, input[type="number"] {
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    background: white;
    min-width: 60px;
}

.custom-input {
    width: 50px;
    margin-left: 4px;
}

/* Button styling - optimized for limited height */
button {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    white-space: nowrap;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    background: linear-gradient(145deg, #45a049, #4CAF50);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#resetBtn {
    background: linear-gradient(145deg, #f44336, #d32f2f);
}

#resetBtn:hover {
    background: linear-gradient(145deg, #d32f2f, #f44336);
}

/* Content area with split panels */
.content-area {
    flex: 1;
    display: flex;
    gap: 2px;
    padding: 2px;
    overflow: hidden;
}

.panel {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    cursor: help;
}

/* Canvas styling */
canvas {
    flex: 1;
    background: #fafafa;
    border-radius: 0 0 8px 8px;
    cursor: crosshair;
}

/* Values display */
.values-display {
    display: flex;
    justify-content: space-around;
    padding: 6px;
    background: rgba(102, 126, 234, 0.1);
    font-size: 11px;
    font-weight: 600;
}

.value-item {
    color: #555;
    text-align: center;
}

/* Critical angle indicator */
.critical-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    animation: pulse 1s infinite;
    z-index: 10;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.05); }
}

/* Modal styling */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 12px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.examples-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.example-btn {
    padding: 12px;
    background: linear-gradient(145deg, #2196F3, #1976D2);
    font-size: 12px;
}

.example-btn:hover {
    background: linear-gradient(145deg, #1976D2, #2196F3);
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 200px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        gap: 4px;
        padding: 6px;
    }
    
    .control-group {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .content-area {
        flex-direction: column;
    }
    
    .panel {
        min-height: 150px;
    }
    
    canvas {
        min-height: 120px;
    }
    
    button {
        min-height: 32px;
        min-width: 32px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    button {
        min-height: 36px;
        padding: 8px 12px;
    }
    
    .slider {
        height: 24px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 22px;
        height: 22px;
    }
}